//
//  DepRecordController.m
//  HarmonizePub
//
//  Created by rzhy on 2016/10/13.
//  Copyright © 2016年 Zy. All rights reserved.
//

#import "DepRecordController.h"
#import "Config.h"
#import "DiagnosisController.h"
#import "PrescriptionController.h"
#import "MZCostController.h"

static NSString * const CellIdentifier = @"Cell";

@interface DepRecordController () <UITableViewDataSource, UITableViewDelegate>
{
    NSArray *_dataArray;
}
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation DepRecordController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = self.dataDict[@"brxm"];
   // _dataArray = @[@"门诊诊断", @"门诊处方", @"门诊费用"];
    _dataArray = @[@"门诊诊断", @"门诊处方"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - tableView delegate/dataSource Method
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.textLabel.text = _dataArray[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    NSString *title = _dataArray[indexPath.row];
    if ([title isEqualToString:@"门诊诊断"]) {
        DiagnosisController *diagnosis = [[DiagnosisController alloc] init];
        diagnosis.dataDict = self.dataDict;
        [self.navigationController pushViewController:diagnosis animated:YES];
    } else if ([title isEqualToString:@"门诊处方"]) {
        PrescriptionController *prescription = [[PrescriptionController alloc] init];
        prescription.dataDict = self.dataDict;
        [self.navigationController pushViewController:prescription animated:YES];
    }else {
        [self setAlertViewWithMessage:XHAlertMsg];
    }
//    else if ([title isEqualToString:@"门诊费用"]) {
//        MZCostController *mzCost = [[MZCostController alloc] init];
//        mzCost.dataDict = self.dataDict;
//        [self.navigationController pushViewController:mzCost animated:YES];
//    }
}

#pragma mark - AlertView
- (void)setAlertViewWithMessage:(NSString *)message {
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提 示:" message:message preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
    [alertController addAction:defaultAction];
    [self presentViewController:alertController animated:YES completion:nil];
}

@end
